{extend name="public:default" /}

<!-- 搜索栏 -->
{block name="inputBtn"}
    
    <div class="layui-inline marSelect">
        <div class="layui-input-inline">
        <select name="admin_file_p_id">
            <option value="0">根目录</option>
            {if $info}
                {foreach $info as $k => $v}
                    <option value="{$v['id']}">{$v['admin_file_p_title']}</option>
                {/foreach}
            {/if}
        </select>
        </div>
    </div>

    <div class="layui-inline marSelect">
        <div class="layui-input-inline">
        <select name="admin_file_is_show">
            <option value="">请选择限制</option>
            <option value="1">显示</option>
            <option value="0">隐藏</option>
        </select>
        </div>
    </div>
    
    <br>

    <div class="layui-inline">
        <fieldset class="label_title">
            <legend>文件名称</legend>
            <input type="text" name="admin_file_p_title" placeholder="点此输入" autocomplete="off" class="layui-input">
        </fieldset>
    </div>

    <div class="layui-inline">
        <fieldset class="label_title">
            <legend>请选择日期</legend>
            <input type="text" name="admin_file_times" placeholder="点此选择" class="layui-input" id="test-laydate-range-datetime" lay-key="1" readonly>
        </fieldset>
    </div>
    
{/block}

<!-- 头工具栏 -->
{block name="tableTopBtn"}

    <button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del"><i class="layui-icon"></i></button>
    <button class="layui-btn layui-btn-primary layui-btn-sm" lay-event="add"><i class="layui-icon"></i></button>
    
{/block}

<!-- 行工具栏 -->
{block name="tableEndBtn"}

    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon"></i></a>

{/block}


<!-- js 执行方法 -->
{block name="script"}
<script>
    var isShow = function (d){
        return d ? '显示' : '隐藏';
    }

    var editList = window.location.pathname // 列表链接
    var editAdd = editList + 'Add' // 添加链接
    var editUp = editList + 'Up' // 修改链接
    var editDel = editList + 'Del' // 删除链接

    views.setUrl(editAdd,editDel,editUp).cols({
        url: editList,
        page: true,
        cols: [
            {type: 'checkbox', fixed: 'left'}

            ,{field:'id', title:'ID', align:'center',event:'img'}
            ,{field:'admin_file_p_title', title:'名称', align:'center',event:'img'}
            ,{field:'admin_file_url', title:'图片', align:'center',event:'img',width:60,templet:function(d){
                var url = d.admin_file_file == 1 ? '{$yuming}/'+d.admin_file_url : d.admin_file_url ;
                return '<img src="'+url+'" width="100%">' ;
            }}
            
            ,{field:'admin_file_w', title:'图片宽度', align:'center',event:'img'}
            ,{field:'admin_file_h', title:'图片高度', align:'center',event:'img'}
            ,{field:'admin_file_type', title:'图片类型', align:'center',event:'img'}
            
            ,{field:'admin_file_is_show', title:'显示隐藏', align:'center',event:'img', templet:function(d){ return d.admin_user_is_show ? '显示' : '隐藏' ;}}
            ,{field:'admin_file_times', title:'添加时间', align:'center',event:'img', templet:function(d){ return d.admin_user_times ? layui.util.toDateString(d.admin_user_times * 1000) : '' ; }}

            ,{fixed: 'right', title:'操作', toolbar: '#test-table-toolbar-barDemo', width:150}
        ]

    }).toolbar(function(obj,data,table){
        // 头工具栏事件

    }).tool(function(obj,table,tables){
        //监听行工具事件
        if(obj.event == 'img'){
            if(obj.data.admin_file_file == 0){
                tables.reload({
                    url: editList
                    ,where: {
                        'admin_file_p_id':obj.data.id
                    }
                });
                
            }
        }
    }).func(function(table,admin,laydate){
        //日期时间选择器

    }).get();

    
    
</script>
{/block}
  
  